/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package algebra.parallel;

import algebra.MatrixItem;
import algebra.Vector;
import java.util.ArrayList;

/**
 *
 * @author max
 */
public class MatrixRunnable implements Runnable {

    ArrayList<ArrayList<MatrixItem>> mat;
    Vector vec, ret_vec;
    int row,
            //column, 
            vec_start;

    public MatrixRunnable(ArrayList<ArrayList<MatrixItem>> mat, Vector vec, Vector ret_vec, int vec_start) {

        this.mat = mat;
        this.vec = vec;
        this.ret_vec = ret_vec;
        this.row = mat.size();
        this.vec_start = vec_start;

    }

    public void run() {



        for (int i = 0; i < row; i++) {

            double d = 0;


            for (int j = 0; j < mat.get(i).size(); j++) {

                d += mat.get(i).get(j).getvalue() * vec.get(mat.get(i).get(j).getj());

            }

            ret_vec.set(i, d * vec.get(i + vec_start));
        }

    }
}
